package com.itheima.health.mobile.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码Controller
 */
@RestController
@RequestMapping("/mobile/validateCode")
@Slf4j
public class ValidateCodeController {

    @DubboReference
    private SmsService smsService;

    /**
     * @Author: Blackie
     * @Date: 23:40 2021/1/11
     * @Parms [type, telephone]  发送的类型 发送的手机号
     * @ReturnType: com.itheima.health.entity.Result
     * @Description: 发送验证码
     */
    @PostMapping("send")
    public Result send(String type, String telephone, Integer countSend) {
        log.info("[短信控制器-发送验证码]type:{},telephone:{},countSend:{}", type, telephone, countSend);
        //rpc调用发送验证码
        smsService.sendValidateCode(type, telephone, countSend);
        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS);
    }
}
